/*
 * 基于GPLv2发布
 * 2007/12/16
 * 作者：旅行者2号
 * laf163@gmail.com
 */

#include <QApplication>
#include <QTextCodec>
#include "MainDialog.h"
#include "stdio.h"
#include <SelectNetDialog.h>
#include <QFile>

#ifdef WIN32
	#define PATH_MAX MAX_PATH
#endif

MainDialog *pMainDlg;

int main(int argc, char *argv[])
{
	QApplication app(argc, argv,true);
	QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
	QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
	QSettings settings("ShadaLinux", "ShadaArp");
	QFont font;
	font.setFamily(settings.value("appfont","Sans Serif").toString());
	font.setPointSize(settings.value("appfontsize",12).toInt());
	app.setFont(font);
#ifndef WIN32
	if(geteuid()!=0){
		char s_cmd[PATH_MAX];
		if(QFile::exists("/usr/bin/gksu"))strcpy(s_cmd,"gksu ");
		else strcpy(s_cmd,"kdesu ");
		strcat(s_cmd,argv[0]);
		system(s_cmd);
		exit(0);
	}
	printf("OS: Linux.\n");
#else
	printf("OS: Windows.\n");
#endif
	printf("Show SelectNetDialog.\n");
	SelectNetDialog *pSnd=new SelectNetDialog;
	pSnd->exec();
	printf("Show MainDialog.\n");
	pMainDlg=new MainDialog;
	pMainDlg->show();
	int ret=app.exec();
	printf("Closed.\n");
	fclose(stdout);
	return ret;
}


